<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:forEach var="record" items="${results}" varStatus="status"><span class="medical-s" mid="${record.uuid}" price="${record.price}">${record.medicalName}</span></c:forEach>
<script>
    $(".medical-s").click(function(){

        var mid = $(this).attr("mid");
        var exist = false;
        $(".medical-cell").each(function(){
            if(mid==$(this).attr("dataId")){
                exist = true;
                return ;
            }
        });

        if(exist){
            $.toast( $(this).text()+"已经存在,无需重复添加","text");
            return ;
        }
        var mid =$(this).attr("mid");
        var price =$(this).attr("price");
        var html = "<div class=\"medical-cell\" dataId=\""+mid+"\" >\n" +
                "<input type='hidden' name='medPrice' value='"+price+"'/>"+
            "<input type='hidden' name='medId' value='"+mid+"'/>"+
            " <i class=\"fa fa-minus-circle\" aria-hidden=\"true\"></i> <span class=\"mname\">"+$(this).text() +
            " </span><span class=\"kk-fr\"><input class=\"short-input\"  price=\""+price+"\" name=\"medNum\" type=\"number\" id=\"m_"+mid+"\"> g</span>" +
            "</div>";
        $(".medical-cells").append(html);


        setTimeout(function () {
            document.getElementById("m_"+mid).select();
        },400);

    });


</script>
